Skip to content

ext/gd: pack imageloadfont short-read test in native byte order#22416

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:gd-imageloadfont-test-endian
Open

ext/gd: pack imageloadfont short-read test in native byte order#22416
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:gd-imageloadfont-test-endian

Conversation

@iliaal

@iliaal iliaal commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

The imageloadfont_short_read test packed the font header with pack('V4', ...) (little-endian), but imageloadfont() reads it as native-endian ints, so on big-endian hosts the byte-swapped values trip the INT_MAX overflow guard before the FLIPWORD fallback and the font is rejected. Packing with pack('i4', ...) keeps the header valid on both, fixing the PPC64 nightly failure.

imageloadfont_short_read packed the font header with pack('V4', ...)
(little-endian), but imageloadfont() reads the header as native-endian
ints. On big-endian hosts (PPC64 nightly) the byte-swapped values
overflow the INT_MAX guard before the FLIPWORD fallback runs, so the
font is rejected and the test fails. Pack the fields with 'i' to keep
the header valid regardless of host endianness.
@devnexen

Copy link
Copy Markdown
Member

@iliaal I would recommend to enable CI for PPC64 (look at the labels) since this is where the issue was from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants